package com.example.UserService;

import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

public class UserServiceTest {
    private UserService userService;

    @BeforeEach
    public void setUp() {
        userService = new UserService();
    }

    @Test
    public void testRegisterSuccess() {
        assertTrue(userService.register("testUser", "password123"));
    }

    @Test
    public void testRegisterWithNullUsername() {
        Exception exception = assertThrows(IllegalArgumentException.class, () -> {
            userService.register(null, "password123");
        });
        assertEquals("用户名和密码不能为空", exception.getMessage());
    }
}
